The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 014
MANIFEST 011
META.yml 35
Makefile.PL 16
README 0675
inc/Module/Install/Base.pm 2421
inc/Module/Install/Can.pm 77
inc/Module/Install/Fetch.pm 44
inc/Module/Install/Makefile.pm 55
inc/Module/Install/Metadata.pm 3074
inc/Module/Install/Win32.pm 33
inc/Module/Install/WriteAll.pm 414
inc/Module/Install.pm 33
lib/HTML/FormFu/Model/DBIC.pm 129178
t/create/basic.t 42
t/default_values/basic.t 42
t/default_values/basic_nested.t 42
t/default_values/belongs_to_lookup_table.t 42
t/default_values/belongs_to_lookup_table_combobox.t 42
t/default_values/empty_rows_zero.t 42
t/default_values/has_many_combobox.t 42
t/default_values/has_many_repeatable.t 42
t/default_values/has_many_repeatable_delete_true.t 42
t/default_values/has_many_repeatable_label.t 42
t/default_values/has_many_repeatable_nested.t 42
t/default_values/has_many_repeatable_new.t 42
t/default_values/has_many_select.t 42
t/default_values/has_one.t 42
t/default_values/has_one_nested.t 42
t/default_values/label.t 42
t/default_values/many_to_many-has_many.t 42
t/default_values/many_to_many_checkboxgroup.t 050
t/default_values/many_to_many_checkboxgroup.yml 015
t/default_values/many_to_many_repeatable.t 42
t/default_values/many_to_many_repeatable_nested.t 42
t/default_values/many_to_many_repeatable_new.t 42
t/default_values/many_to_many_select.t 42
t/default_values/many_to_many_select_nested.t 42
t/default_values/methods.t 42
t/default_values/might_have.t 42
t/default_values/might_have_missing.t 42
t/default_values/multi_label.t 42
t/default_values/nested_name_accessor.t 42
t/default_values/opt_accessor.t 42
t/default_values/opt_accessor_nested.t 42
t/deprecated-defaults_from_model/basic.t 42
t/deprecated-defaults_from_model/basic_nested.t 42
t/deprecated-defaults_from_model/belongs_to_lookup_table.t 42
t/deprecated-defaults_from_model/has_many_repeatable.t 42
t/deprecated-defaults_from_model/has_many_repeatable_nested.t 42
t/deprecated-defaults_from_model/has_many_repeatable_new.t 42
t/deprecated-defaults_from_model/has_many_select.t 42
t/deprecated-defaults_from_model/has_one.t 42
t/deprecated-defaults_from_model/has_one_nested.t 42
t/deprecated-defaults_from_model/many_to_many_repeatable.t 42
t/deprecated-defaults_from_model/many_to_many_repeatable_nested.t 42
t/deprecated-defaults_from_model/many_to_many_repeatable_new.t 42
t/deprecated-defaults_from_model/many_to_many_select.t 42
t/deprecated-defaults_from_model/many_to_many_select_nested.t 42
t/deprecated-defaults_from_model/methods.t 42
t/deprecated-defaults_from_model/might_have.t 42
t/deprecated-defaults_from_model/might_have_missing.t 42
t/deprecated-defaults_from_model/opt_accessor.t 42
t/deprecated-defaults_from_model/opt_accessor_nested.t 42
t/deprecated-new_empty_row/default_values/has_many_repeatable_new.t 42
t/deprecated-new_empty_row/default_values/many_to_many_repeatable_new.t 42
t/deprecated-new_empty_row/update/has_many_repeatable_new.t 42
t/deprecated-new_empty_row/update/has_many_repeatable_new_date.t 42
t/deprecated-new_empty_row/update/has_many_repeatable_new_empty.t 42
t/deprecated-new_empty_row_multi/update/has_many_repeatable_many_new.t 42
t/deprecated-save_to_model/add_valid.t 42
t/deprecated-save_to_model/basic_create.t 42
t/deprecated-save_to_model/basic_update.t 42
t/deprecated-save_to_model/belongs_to.t 42
t/deprecated-save_to_model/column_without_field.t 42
t/deprecated-save_to_model/has_many_repeatable.t 42
t/deprecated-save_to_model/has_many_repeatable_delete_true.t 42
t/deprecated-save_to_model/has_many_repeatable_new.t 42
t/deprecated-save_to_model/has_many_repeatable_new_empty.t 42
t/deprecated-save_to_model/has_one.t 42
t/deprecated-save_to_model/has_one_create.t 42
t/deprecated-save_to_model/has_one_no_id.t 42
t/deprecated-save_to_model/many_to_many_repeatable.t 42
t/deprecated-save_to_model/many_to_many_select.t 42
t/deprecated-save_to_model/many_to_many_select_unselected.t 42
t/deprecated-save_to_model/methods.t 42
t/deprecated-save_to_model/might_have.t 42
t/deprecated-save_to_model/might_have_create.t 42
t/deprecated-save_to_model/might_have_delete_if_empty.t 42
t/deprecated-save_to_model/nested_create.t 42
t/deprecated-save_to_model/nested_create_checkbox.t 42
t/deprecated-save_to_model/opt_accessor.t 42
t/deprecated-save_to_model/opt_accessor_nested.t 42
t/deprecated-save_to_model/unchecked_not_null_checkbox.t 42
t/lib/DBICTestLib.pm 1569
t/lib/MySchema/Address.pm 11
t/lib/MySchema/Band.pm 11
t/lib/MySchema/Master.pm 1010
t/lib/MySchema/Schedule.pm 02
t/lib/MySchema/Task.pm 023
t/lib/MySchema/TwoNote.pm 022
t/lib/MySchema/User.pm 11
t/lib/MySchema/UserBand.pm 04
t/options_from_model/belongs_to.t 42
t/options_from_model/belongs_to_combobox.t 42
t/options_from_model/belongs_to_config_zero.t 42
t/options_from_model/belongs_to_config_zero_combobox.t 42
t/options_from_model/belongs_to_localize_label.t 42
t/options_from_model/condition_from_stash.t 42
t/options_from_model/condition_from_stash_combobox.t 42
t/options_from_model/constraint_autoset.t 42
t/options_from_model/has_many_repeatable_select.t 42
t/options_from_model/many_to_many_select.t 42
t/update/add_valid.t 42
t/update/basic_create.t 42
t/update/basic_update.t 42
t/update/belongs_to.t 42
t/update/belongs_to_combobox.t 42
t/update/belongs_to_select.t 2855
t/update/belongs_to_select_two.yml 08
t/update/column_without_field.t 42
t/update/has_many_repeatable.t 42
t/update/has_many_repeatable_delete_true.t 42
t/update/has_many_repeatable_many_new.t 42
t/update/has_many_repeatable_many_new_exceed_max.t 42
t/update/has_many_repeatable_new.t 42
t/update/has_many_repeatable_new_date.t 42
t/update/has_many_repeatable_new_dependon.t 42
t/update/has_many_repeatable_new_empty.t 42
t/update/has_many_repeatable_new_implicit.t 42
t/update/has_many_repeatable_new_required_when.t 42
t/update/has_one.t 42
t/update/has_one_create.t 42
t/update/has_one_no_id.t 42
t/update/has_one_select.t 42
t/update/ignore_if_empty.t 42
t/update/many_to_many-has_many.t 42
t/update/many_to_many_checkboxgroup.t 075
t/update/many_to_many_checkboxgroup.yml 015
t/update/many_to_many_checkboxgroup_unselected.t 071
t/update/many_to_many_repeatable.t 42
t/update/many_to_many_repeatable_new.t 42
t/update/many_to_many_select.t 42
t/update/many_to_many_select_unselected.t 42
t/update/methods.t 42
t/update/might_have.t 42
t/update/might_have_create.t 42
t/update/might_have_delete_if_empty.t 42
t/update/nested_create.t 42
t/update/nested_create_checkbox.t 42
t/update/nested_name_accessor.t 42
t/update/nested_repeatable_write.t 076
t/update/nested_repeatable_write.yml 038
t/update/opt_accessor.t 42
t/update/opt_accessor_nested.t 42
t/update/unchecked_not_null_checkbox.t 42
t/x_roundtrip/checkbox_false2true.t 42
t/x_roundtrip/checkbox_true2false.t 42
158 files changed (This is a version diff) 9141748
@@ -1,3 +1,17 @@
+0.06000 2009-12-10
+
+    - Test suite now uses in-memory SQLite database, so tests can be run in
+      parallel.
+    
+    - many-to-many Checkboxgroup tests.
+
+0.05003 2009-11-25
+
+    - New 'link_values' and 'additive' options for multi-value fields for
+      many-to-many relationships.
+    
+    - Doc updates.
+
 0.05002 2009-07-06
 
     - Remove prerequisite Test::MockObject - it uses UNIVERSAL::isa which
@@ -11,6 +11,7 @@ lib/HTML/FormFu/Model/DBIC.pm
 Makefile.PL
 MANIFEST			This list of files
 META.yml
+README
 t/create/basic.t
 t/create/basic.yml
 t/default_values/basic.t
@@ -45,6 +46,8 @@ t/default_values/label.t
 t/default_values/label.yml
 t/default_values/many_to_many-has_many.t
 t/default_values/many_to_many-has_many.yml
+t/default_values/many_to_many_checkboxgroup.t
+t/default_values/many_to_many_checkboxgroup.yml
 t/default_values/many_to_many_repeatable.t
 t/default_values/many_to_many_repeatable.yml
 t/default_values/many_to_many_repeatable_nested.t
@@ -167,6 +170,8 @@ t/lib/MySchema/Manager.pm
 t/lib/MySchema/Master.pm
 t/lib/MySchema/Note.pm
 t/lib/MySchema/Schedule.pm
+t/lib/MySchema/Task.pm
+t/lib/MySchema/TwoNote.pm
 t/lib/MySchema/Type.pm
 t/lib/MySchema/Type2.pm
 t/lib/MySchema/User.pm
@@ -199,6 +204,7 @@ t/update/belongs_to.t
 t/update/belongs_to_combobox.t
 t/update/belongs_to_select.t
 t/update/belongs_to_select.yml
+t/update/belongs_to_select_two.yml
 t/update/column_without_field.t
 t/update/column_without_field.yml
 t/update/has_many_repeatable.t
@@ -229,6 +235,9 @@ t/update/has_one_select.yml
 t/update/ignore_if_empty.t
 t/update/ignore_if_empty.yml
 t/update/many_to_many-has_many.t
+t/update/many_to_many_checkboxgroup.t
+t/update/many_to_many_checkboxgroup.yml
+t/update/many_to_many_checkboxgroup_unselected.t
 t/update/many_to_many_repeatable.t
 t/update/many_to_many_repeatable.yml
 t/update/many_to_many_repeatable_new.t
@@ -248,6 +257,8 @@ t/update/nested.yml
 t/update/nested_create.t
 t/update/nested_create_checkbox.t
 t/update/nested_name_accessor.t
+t/update/nested_repeatable_write.t
+t/update/nested_repeatable_write.yml
 t/update/opt_accessor.t
 t/update/opt_accessor.yml
 t/update/opt_accessor_nested.t
@@ -5,10 +5,11 @@ author:
 build_requires:
   DateTime::Format::SQLite: 0
   ExtUtils::MakeMaker: 6.42
+  SQL::Translator: 0
 configure_requires:
   ExtUtils::MakeMaker: 6.42
 distribution_type: module
-generated_by: 'Module::Install version 0.83'
+generated_by: 'Module::Install version 0.91'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -18,13 +19,14 @@ no_index:
   directory:
     - inc
     - t
+    - xt
 requires:
   DBD::SQLite: 0
-  DBIx::Class: 0.08106
+  DBIx::Class: 0.08108
   HTML::FormFu: 0.05000
   List::MoreUtils: 0
   Task::Weaken: 0
   perl: 5.8.1
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.05002
+version: 0.06000
@@ -1,11 +1,15 @@
 use inc::Module::Install;
 
+if ( -e 'MANIFEST.SKIP' ) {
+    system( 'pod2text lib/HTML/FormFu/Model/DBIC.pm > README' );
+}
+
 name 'HTML-FormFu-Model-DBIC';
 perl_version '5.008001';
 all_from 'lib/HTML/FormFu/Model/DBIC.pm';
 
 requires 'DBD::SQLite';
-requires 'DBIx::Class' => '0.08106';
+requires 'DBIx::Class' => '0.08108';
 # DBIx::Class 0.08106 switched from DateTime::Format::MySQL to ::SQLite
 # Rather than changing our prereqs depending on the installed version
 # of DBIx::Class, just bump the required version
@@ -15,6 +19,7 @@ requires 'List::MoreUtils';
 requires 'Task::Weaken'; # to ensure Scalar::Util was built with weaken()
 
 test_requires 'DateTime::Format::SQLite';
+test_requires 'SQL::Translator'; # for $schema->deploy()
 
 tests_recursive;
 
@@ -0,0 +1,675 @@
+NAME
+    HTML::FormFu::Model::DBIC - Integrate HTML::FormFu with DBIx::Class
+
+SYNOPSIS
+    Example of typical use in a Catalyst controller:
+
+        sub edit : Chained {
+            my ( $self, $c ) = @_;
+        
+            my $form = $c->stash->{form};
+            my $book = $c->stash->{book};
+        
+            if ( $form->submitted_and_valid ) {
+            
+                # update dbic row with submitted values from form
+            
+                $form->model->update( $book );
+            
+                $c->response->redirect( $c->uri_for('view', $book->id) );
+                return;
+            }
+            elsif ( !$form->submitted ) {
+            
+                # use dbic row to set form's default values
+            
+                $form->model->default_values( $book );
+            }
+        
+            return;
+        }
+
+SETUP
+    For the form object to be able to access your DBIx::Class schema, it
+    needs to be placed on the form stash, with the name "schema".
+
+    This is easy if you're using Catalyst-Controller-HTML-FormFu, as you can
+    set this up to happen in your Catalyst app's config file.
+
+    For example, if your model is named "MyApp::Model::Corp", you would set
+    this (in Config::General format):
+
+        <Controller::HTML::FormFu>
+            <model_stash>
+                schema Corp
+            </model_stash>
+        </Controller::HTML::FormFu>
+
+    Or if your app's config file is in YAML format:
+
+        'Controller::HTML::FormFu':
+            model_stash:
+                schema: Corp
+
+METHODS
+  default_values
+    Arguments: $dbic_row, [\%config]
+
+    Return Value: $form
+
+        $form->model->default_values( $dbic_row );
+
+    Set a form's default values from the database, to allow a user to edit
+    them.
+
+  update
+    Arguments: [$dbic_row], [\%config]
+
+    Return Value: $dbic_row
+
+        $form->model->update( $dbic_row );
+
+    Update the database with the submitted form values.
+
+  create
+    Arguments: [\%config]
+
+    Return Value: $dbic_row
+
+        my $dbic_row = $form->model->create( {resultset => 'Book'} );
+
+    Like "update", but doesn't require a $dbic_row argument.
+
+    You need to ensure the DBIC schema is available on the form stash - see
+    "SYNOPSIS" for an example config.
+
+    The "resultset" must be set either in the method arguments, or the form
+    or block's "model_config".
+
+    An example of setting the ResultSet name on a Form:
+
+        ---
+        model_config:
+          resultset: FooTable
+    
+        elements:
+          # [snip]
+
+  options_from_model
+    Populates a multi-valued field with values from the database.
+
+    This method should not be called directly, but is called for you during
+    "$form->process" by fields that inherit from
+    HTML::FormFu::Element::_Group. This includes:
+
+    HTML::FormFu::Element::Select
+    HTML::FormFu::Element::Checkboxgroup
+    HTML::FormFu::Element::Radiogroup
+    HTML::FormFu::Element::ComboBox
+
+    To use you must set the appropriate "resultset" on the element
+    "model_config":
+
+        element:
+          - type: Select
+            name: foo
+            model_config:
+              resultset: TableClass
+
+BUILDING FORMS
+  single table
+    To edit the values in a row with no related rows, the field names simply
+    have to correspond to the database column names.
+
+    For the following DBIx::Class schema:
+
+        package MySchema::Book;
+        use base 'DBIx::Class';
+    
+        __PACKAGE__->load_components(qw/ Core /);
+    
+        __PACKAGE__->table("book");
+    
+        __PACKAGE__->add_columns(
+            id     => { data_type => "INTEGER" },
+            title  => { data_type => "TEXT" },
+            author => { data_type => "TEXT" },
+            blurb  => { data_type => "TEXT" },
+        );
+    
+        __PACKAGE__->set_primary_key("id");
+    
+        1;
+
+    A suitable form for this might be:
+
+        elements:
+          - type: Text
+            name: title
+      
+          - type: Text
+            name: author
+      
+          - type: Textarea
+            name: blurb
+
+  might_have and has_one relationships
+    Set field values from a related row with a "might_have" or "has_one"
+    relationship by placing the fields within a Block (or any element that
+    inherits from Block, such as Fieldset) with its "nested_name" in
+    HTML::FormFu set to the relationship name.
+
+    For the following DBIx::Class schemas:
+
+        package MySchema::Book;
+        use base 'DBIx::Class';
+    
+        __PACKAGE__->load_components(qw/ Core /);
+    
+        __PACKAGE__->table("book");
+    
+        __PACKAGE__->add_columns(
+            id    => { data_type => "INTEGER" },
+            title => { data_type => "TEXT" },
+        );
+    
+        __PACKAGE__->set_primary_key("id");
+    
+        __PACKAGE__->might_have( review => 'MySchema::Review', 'book' );
+    
+        1;
+
+
+        package MySchema::Review;
+        use base 'DBIx::Class';
+    
+        __PACKAGE__->load_components(qw/ Core /);
+    
+        __PACKAGE__->table("review");
+    
+        __PACKAGE__->add_columns(
+            id          => { data_type => "INTEGER" },
+            book        => { data_type => "INTEGER", is_nullable => 1 },
+            review_text => { data_type => "TEXT" },
+        );
+    
+        __PACKAGE__->set_primary_key("book");
+    
+        __PACKAGE__->belongs_to( book => 'MySchema::Book' );
+    
+        1;
+
+    A suitable form for this would be:
+
+        elements:
+          - type: Text
+            name: title
+      
+          - type: Block
+            nested_name: review
+            elements:
+              - type: Textarea
+                name: review_text
+
+    For "might_have" and "has_one" relationships, you generally shouldn't
+    need to have a field for the related table's primary key, as DBIx::Class
+    will handle retrieving the correct row automatically.
+
+    You can also set a "has_one" or "might_have" relationship using a multi
+    value field like Select.
+
+        elements:
+          - type: Text
+            name: title
+      
+          - type: Select
+            nested: review
+            model_config:
+              resultset: Review
+
+    This will load all reviews into the select field. If you select a review
+    from that list, a current relationship to a review is removed and the
+    new one is added. This requires that the primary key of the "Review"
+    table and the foreign key do not match.
+
+  has_many and many_to_many relationships
+    The general principle is the same as for "might_have" and "has_one"
+    above, except you should use a Repeatable element instead of a Block,
+    and it needs to contain a Hidden field corresponding to the foreign key.
+
+    The Repeatable block's nested_name must be set to the name of the
+    relationship.
+
+    The Repeable block's increment_field_names must be true (which is the
+    default value).
+
+    The Repeable block's counter_name must be set to the name of a Hidden
+    field, which is placed outside of the Repeatable block. This field is
+    used to store a count of the number of repetitions of the Repeatable
+    block were created. When the form is submitted, this value is used
+    during "$form->process" to ensure the form is rebuilt with the correct
+    number of repetitions.
+
+    For the following DBIx::Class schemas:
+
+        package MySchema::Book;
+        use base 'DBIx::Class';
+    
+        __PACKAGE__->load_components(qw/ Core /);
+    
+        __PACKAGE__->table("book");
+    
+        __PACKAGE__->add_columns(
+            id    => { data_type => "INTEGER" },
+            title => { data_type => "TEXT" },
+        );
+    
+        __PACKAGE__->set_primary_key("id");
+    
+        __PACKAGE__->has_many( review => 'MySchema::Review', 'book' );
+    
+        1;
+
+
+        package MySchema::Review;
+        use base 'DBIx::Class';
+    
+        __PACKAGE__->load_components(qw/ Core /);
+    
+        __PACKAGE__->table("review");
+    
+        __PACKAGE__->add_columns(
+            book        => { data_type => "INTEGER" },
+            review_text => { data_type => "TEXT" },
+        );
+    
+        __PACKAGE__->set_primary_key("book");
+    
+        __PACKAGE__->belongs_to( book => 'MySchema::Book' );
+    
+        1;
+
+    A suitable form for this would be:
+
+        elements:
+          - type: Text
+            name: title
+      
+          - type: Hidden
+            name: review_count
+      
+          - type: Repeatable
+            nested_name: review
+            counter_name: review_count
+            elements:
+              - type: Hidden
+                name: book
+          
+              - type: Textarea
+                name: review_text
+
+  many_to_many selection
+    To select / deselect rows from a "many_to_many" relationship, you must
+    use a multi-valued element, such as a Checkboxgroup or a Select with
+    multiple set.
+
+    The field's name must be set to the name of the "many_to_many"
+    relationship.
+
+    default_column
+        If you want to search / associate the related table by a column
+        other it's primary key, set
+        "$field->model_config->{default_column}".
+
+            ---
+            element:
+                - type: Checkboxgroup
+                  name: authors
+                  model_config:
+                    default_column: foo
+
+        If you want to set columns on the link table you can do so if you
+        add a "link_values" attribute to "model_config":
+
+            ---
+            element:
+                - type: Checkboxgroup
+                  name: authors
+                  model_config:
+                    link_values:
+                      foo: bar
+
+        The default implementation will first remove all related objects and
+        set the new ones (see
+        <http://search.cpan.org/perldoc?DBIx::Class::Relationship::Base#set_
+        $rel>). If you want to add the selected objects to the current set
+        of objects set "additive" in the "model_config".
+
+            ---
+            element:
+                - type: Checkboxgroup
+                  name: authors
+                  model_config:
+                    additive: 1
+                    options_from_model: 0
+
+        (<options_from_model> is set to 0 because this "options_from_model"
+        will try to fetch all objects from the result class "Authors" if
+        "model_config" is specified without a "resultset" attribute.)
+
+COMMON ARGUMENTS
+    The following items are supported in the optional "config" hash-ref
+    argument to the methods default_values, update and create.
+
+    base
+        If you want the method to process a particular Block element, rather
+        than the whole form, you can pass the element as a "base" argument.
+
+            $form->default_values(
+                $row,
+                {
+                    base => $formfu_element,
+                },
+            );
+
+    nested_base
+        If you want the method to process a particular Block element by
+        name, you can pass the name as an argument.
+
+            $form->default_values(
+                $row,
+                {
+                    nested_base => 'foo',
+                }'
+            );
+
+CONFIGURATION
+  Config options for fields
+    The following items are supported as "model_config" options on form
+    fields.
+
+    accessor
+        If set, "accessor" will be used as a method-name accessor on the
+        "DBIx::Class" row object, instead of using the field name.
+
+    delete_if_empty
+        Useful for editing a "might_have" related row containing only one
+        field.
+
+        If the submitted value is blank, the related row is deleted.
+
+        For the following DBIx::Class schemas:
+
+            package MySchema::Book;
+            use base 'DBIx::Class';
+    
+            __PACKAGE__->load_components(qw/ Core /);
+    
+            __PACKAGE__->table("book");
+    
+            __PACKAGE__->add_columns(
+                id    => { data_type => "INTEGER" },
+                title => { data_type => "TEXT" },
+            );
+    
+            __PACKAGE__->set_primary_key("id");
+    
+            __PACKAGE__->might_have( review => 'MySchema::Review', 'book' );
+    
+            1;
+
+
+            package MySchema::Review;
+            use base 'DBIx::Class';
+    
+            __PACKAGE__->load_components(qw/ Core /);
+    
+            __PACKAGE__->table("review");
+    
+            __PACKAGE__->add_columns(
+                book        => { data_type => "INTEGER" },
+                review_text => { data_type => "TEXT" },
+            );
+    
+            __PACKAGE__->set_primary_key("book");
+    
+            __PACKAGE__->belongs_to( book => 'MySchema::Book' );
+    
+            1;
+
+        A suitable form for this would be:
+
+            elements:
+              - type: Text
+                name: title
+      
+              - type: Block
+                nested_name: review
+                elements:
+                  - type: Text
+                    name: review_text
+                    model_config:
+                      delete_if_empty: 1
+
+    label
+        To use a column value for a form field's label.
+
+  Config options for fields within a Repeatable block
+    delete_if_true
+        Intended for use on a Checkbox field.
+
+        If the checkbox is checked, the following occurs: for a has-many
+        relationship, the related row is deleted; for a many-to-many
+        relationship, the relationship link is removed.
+
+        An example of use might be:
+
+            elements:
+              - type: Text
+                name: title
+      
+              - type: Hidden
+                name: review_count
+      
+              - type: Repeatable
+                nested_name: review
+                counter_name: review_count
+                elements:
+                  - type: Hidden
+                    name: book
+          
+                  - type: Textarea
+                    name: review_text
+          
+                  - type: Checkbox
+                    name: delete_review
+                    label: 'Delete Review?'
+                    model_config:
+                      delete_if_true: 1
+
+        Note: make sure the name of this field does not clash with one of
+        your DBIx::Class::Row method names (e.g. "delete") - see "CAVEATS".
+
+  Config options for Repeatable blocks
+    empty_rows
+        For a Repeatable block corresponding to a has-many or many-to-many
+        relationship, to allow the user to insert new rows, set "empty_rows"
+        to the number of extra repetitions you wish added to the end of the
+        Repeatable block.
+
+    new_rows_max
+        Set to the maximum number of new rows that a Repeatable block is
+        allowed to add.
+
+        If not set, it will fallback to the value of "empty_rows".
+
+  Config options for options_from_model
+    The column used for the element values is set with the "model_config"
+    value "id_column" - or if not set, the table's primary column is used.
+
+        element:
+          - type: Select
+            name: foo
+            model_config:
+              resultset: TableClass
+              id_column: pk_col
+
+    The column used for the element labels is set with the "model_config"
+    value "label_column" - or if not set, the first text/varchar column
+    found in the table is used - or if one is not found, the "id_column" is
+    used instead.
+
+        element:
+          - type: Select
+            name: foo
+            model_config:
+              resultset: TableClass
+              label_column: label_col
+
+    To pass the database label values via the form's localization object,
+    set "localize_label"
+
+        element:
+          - type: Select
+            name: foo
+            model_config:
+              localize_label: 1
+
+    You can set a "condition", which will be passed as the 1st arguement to
+    "search" in DBIx::Class::ResultSet.
+
+        element:
+          - type: Select
+            name: foo
+            model_config:
+              resultset: TableClass
+              condition:
+                type: is_foo
+
+    You can set "attributes", which will be passed as the 2nd arguement to
+    "search" in DBIx::Class::ResultSet.
+
+FAQ
+  Add extra values not in the form
+    To update values to the database which weren't submitted to the form,
+    you can first add them to the form with add_valid.
+
+        my $passwd = generate_passwd();
+    
+        $form->add_valid( passwd => $passwd );
+    
+        $form->model->update( $row );
+
+    "add_valid" works for fieldnames that don't exist in the form.
+
+  Set a field read only
+    You can make a field read only. The value of such fields cannot be
+    changed by the user even if they submit a value for it.
+
+      $field->model_config->{read_only} = 1;
+  
+      - Name: field
+        model_config:
+          read_only: 1
+
+    See HTML::FormFu::Element::Label.
+
+DEPRECATED
+  new_empty_row
+    Is deprecated and provided only for backwards compatability. Will be
+    removed at some point in the future.
+
+    See "empty_rows" in "Config options for Repeatable blocks" instead.
+
+  new_empty_row_multi
+    Is deprecated and provided only for backwards compatability. Will be
+    removed at some point in the future.
+
+    See "new_rows_max" in "Config options for Repeatable blocks" instead.
+
+  Range constraint
+    The suggestion to use a "Range" constraint on the "count" field to limit
+    the number of repetitions of a Repeatable block, has been withdrawn.
+
+    This was only useful in the case that there were no initial rows to be
+    edited, otherwise the "max()" value could not be known ahead of time.
+
+    See "empty_rows" in "Config options for Repeatable blocks" instead.
+
+CAVEATS
+    To ensure your column's inflators and deflators are called, we have to
+    get / set values using their named methods, and not with "get_column" /
+    "set_column".
+
+    Because of this, beware of having column names which clash with
+    DBIx::Class built-in method-names, such as "delete". - It will have
+    obviously undesirable results!
+
+SUPPORT
+    Project Page:
+
+    <http://code.google.com/p/html-formfu/>
+
+    Mailing list:
+
+    <http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu>
+
+    Mailing list archives:
+
+    <http://lists.scsys.co.uk/pipermail/html-formfu/>
+
+BUGS
+    Please submit bugs / feature requests to
+    <http://code.google.com/p/html-formfu/issues/list> (preferred) or
+    <http://rt.perl.org>.
+
+SUBVERSION REPOSITORY
+    The publicly viewable subversion code repository is at
+    <http://html-formfu.googlecode.com/svn/trunk/HTML-FormFu-Model-DBIC>.
+
+    If you wish to contribute, you'll need a GMAIL email address. Then just
+    ask on the mailing list for commit access.
+
+    If you wish to contribute but for some reason really don't want to sign
+    up for a GMAIL account, please post patches to the mailing list
+    (although you'll have to wait for someone to commit them).
+
+    If you have commit permissions, use the HTTPS repository url:
+    <https://html-formfu.googlecode.com/svn/trunk/HTML-FormFu-Model-DBIC>
+
+SEE ALSO
+    HTML::FormFu, DBIx::Class, Catalyst::Controller::HTML::FormFu
+
+AUTHOR
+    Carl Franks
+
+CONTRIBUTORS
+    Based on the code of "DBIx::Class::HTML::FormFu", which was contributed
+    to by:
+
+    Adam Herzog
+
+    Daisuke Maki
+
+    Mario Minati
+
+COPYRIGHT AND LICENSE
+    Copyright (C) 2007 by Carl Franks
+
+    Based on the original source code of DBIx::Class::HTMLWidget, copyright
+    Thomas Klausner.
+
+    This library is free software; you can redistribute it and/or modify it
+    under the same terms as Perl itself, either Perl version 5.8.8 or, at
+    your option, any later version of Perl 5 you may have available.
+
+POD ERRORS
+    Hey! The above document had some coding errors, which are explained
+    below:
+
+    Around line 1403:
+        '=item' outside of any '=over'
+
+    Around line 1444:
+        You forgot a '=back' before '=head1'
+
@@ -1,7 +1,11 @@
 #line 1
 package Module::Install::Base;
 
-$VERSION = '0.83';
+use strict 'vars';
+use vars qw{$VERSION};
+BEGIN {
+	$VERSION = '0.91';
+}
 
 # Suspend handler for "redefined" warnings
 BEGIN {
@@ -9,42 +13,34 @@ BEGIN {
 	$SIG{__WARN__} = sub { $w };
 }
 
-### This is the ONLY module that shouldn't have strict on
-# use strict;
-
-#line 41
+#line 42
 
 sub new {
-	my ($class, %args) = @_;
-
-	foreach my $method ( qw(call load) ) {
-		next if defined &{"$class\::$method"};
-		*{"$class\::$method"} = sub {
-			shift()->_top->$method(@_);
-		};
+	my $class = shift;
+	unless ( defined &{"${class}::call"} ) {
+		*{"${class}::call"} = sub { shift->_top->call(@_) };
 	}
-
-	bless( \%args, $class );
+	unless ( defined &{"${class}::load"} ) {
+		*{"${class}::load"} = sub { shift->_top->load(@_) };
+	}
+	bless { @_ }, $class;
 }
 
-#line 62
+#line 61
 
 sub AUTOLOAD {
-	my $self = shift;
 	local $@;
-	my $autoload = eval {
-		$self->_top->autoload
-	} or return;
-	goto &$autoload;
+	my $func = eval { shift->_top->autoload } or return;
+	goto &$func;
 }
 
-#line 79
+#line 75
 
 sub _top {
 	$_[0]->{_top};
 }
 
-#line 94
+#line 90
 
 sub admin {
 	$_[0]->_top->{admin}
@@ -52,7 +48,7 @@ sub admin {
 	Module::Install::Base::FakeAdmin->new;
 }
 
-#line 110
+#line 106
 
 sub is_admin {
 	$_[0]->admin->VERSION;
@@ -63,6 +59,7 @@ sub DESTROY {}
 package Module::Install::Base::FakeAdmin;
 
 my $fake;
+
 sub new {
 	$fake ||= bless(\@_, $_[0]);
 }
@@ -78,4 +75,4 @@ BEGIN {
 
 1;
 
-#line 157
+#line 154
@@ -2,16 +2,16 @@
 package Module::Install::Can;
 
 use strict;
-use Module::Install::Base;
-use Config              ();
-use File::Spec          ();
-use ExtUtils::MakeMaker ();
+use Config                ();
+use File::Spec            ();
+use ExtUtils::MakeMaker   ();
+use Module::Install::Base ();
 
-use vars qw{$VERSION $ISCORE @ISA};
+use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.83';
+	$VERSION = '0.91';
+	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
-	@ISA     = qw{Module::Install::Base};
 }
 
 # check if we can load some module
@@ -2,13 +2,13 @@
 package Module::Install::Fetch;
 
 use strict;
-use Module::Install::Base;
+use Module::Install::Base ();
 
-use vars qw{$VERSION $ISCORE @ISA};
+use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.83';
+	$VERSION = '0.91';
+	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
-	@ISA     = qw{Module::Install::Base};
 }
 
 sub get_file {
@@ -2,14 +2,14 @@
 package Module::Install::Makefile;
 
 use strict 'vars';
-use Module::Install::Base;
-use ExtUtils::MakeMaker ();
+use ExtUtils::MakeMaker   ();
+use Module::Install::Base ();
 
-use vars qw{$VERSION $ISCORE @ISA};
+use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.83';
+	$VERSION = '0.91';
+	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
-	@ISA     = qw{Module::Install::Base};
 }
 
 sub Makefile { $_[0] }
@@ -2,18 +2,17 @@
 package Module::Install::Metadata;
 
 use strict 'vars';
-use Module::Install::Base;
+use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.83';
-	@ISA     = qw{Module::Install::Base};
+	$VERSION = '0.91';
+	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
 
 my @boolean_keys = qw{
 	sign
-	mymeta
 };
 
 my @scalar_keys = qw{
@@ -440,21 +439,21 @@ sub license_from {
 	/ixms ) {
 		my $license_text = $1;
 		my @phrases      = (
-			'under the same (?:terms|license) as perl itself' => 'perl',        1,
-			'GNU general public license'                      => 'gpl',         1,
-			'GNU public license'                              => 'gpl',         1,
-			'GNU lesser general public license'               => 'lgpl',        1,
-			'GNU lesser public license'                       => 'lgpl',        1,
-			'GNU library general public license'              => 'lgpl',        1,
-			'GNU library public license'                      => 'lgpl',        1,
-			'BSD license'                                     => 'bsd',         1,
-			'Artistic license'                                => 'artistic',    1,
-			'GPL'                                             => 'gpl',         1,
-			'LGPL'                                            => 'lgpl',        1,
-			'BSD'                                             => 'bsd',         1,
-			'Artistic'                                        => 'artistic',    1,
-			'MIT'                                             => 'mit',         1,
-			'proprietary'                                     => 'proprietary', 0,
+			'under the same (?:terms|license) as (?:perl|the perl programming language) itself' => 'perl', 1,
+			'GNU general public license'         => 'gpl',         1,
+			'GNU public license'                 => 'gpl',         1,
+			'GNU lesser general public license'  => 'lgpl',        1,
+			'GNU lesser public license'          => 'lgpl',        1,
+			'GNU library general public license' => 'lgpl',        1,
+			'GNU library public license'         => 'lgpl',        1,
+			'BSD license'                        => 'bsd',         1,
+			'Artistic license'                   => 'artistic',    1,
+			'GPL'                                => 'gpl',         1,
+			'LGPL'                               => 'lgpl',        1,
+			'BSD'                                => 'bsd',         1,
+			'Artistic'                           => 'artistic',    1,
+			'MIT'                                => 'mit',         1,
+			'proprietary'                        => 'proprietary', 0,
 		);
 		while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
 			$pattern =~ s{\s+}{\\s+}g;
@@ -506,17 +505,29 @@ sub requires_from {
 	}
 }
 
+sub test_requires_from {
+	my $self     = shift;
+	my $content  = Module::Install::_readperl($_[0]);
+	my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
+	while ( @requires ) {
+		my $module  = shift @requires;
+		my $version = shift @requires;
+		$self->test_requires( $module => $version );
+	}
+}
+
 # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to
 # numbers (eg, 5.006001 or 5.008009).
 # Also, convert double-part versions (eg, 5.8)
 sub _perl_version {
 	my $v = $_[-1];
-	$v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e;	
+	$v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e;
 	$v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e;
 	$v =~ s/(\.\d\d\d)000$/$1/;
 	$v =~ s/_.+$//;
 	if ( ref($v) ) {
-		$v = $v + 0; # Numify
+		# Numify
+		$v = $v + 0;
 	}
 	return $v;
 }
@@ -526,23 +537,58 @@ sub _perl_version {
 
 
 ######################################################################
-# MYMETA.yml Support
+# MYMETA Support
 
 sub WriteMyMeta {
 	die "WriteMyMeta has been deprecated";
 }
 
-sub write_mymeta {
+sub write_mymeta_yaml {
 	my $self = shift;
-	
-	# If there's no existing META.yml there is nothing we can do
-	return unless -f 'META.yml';
 
 	# We need YAML::Tiny to write the MYMETA.yml file
 	unless ( eval { require YAML::Tiny; 1; } ) {
 		return 1;
 	}
 
+	# Generate the data
+	my $meta = $self->_write_mymeta_data or return 1;
+
+	# Save as the MYMETA.yml file
+	print "Writing MYMETA.yml\n";
+	YAML::Tiny::DumpFile('MYMETA.yml', $meta);
+}
+
+sub write_mymeta_json {
+	my $self = shift;
+
+	# We need JSON to write the MYMETA.json file
+	unless ( eval { require JSON; 1; } ) {
+		return 1;
+	}
+
+	# Generate the data
+	my $meta = $self->_write_mymeta_data or return 1;
+
+	# Save as the MYMETA.yml file
+	print "Writing MYMETA.json\n";
+	Module::Install::_write(
+		'MYMETA.json',
+		JSON->new->pretty(1)->canonical->encode($meta),
+	);
+}
+
+sub _write_mymeta_data {
+	my $self = shift;
+
+	# If there's no existing META.yml there is nothing we can do
+	return undef unless -f 'META.yml';
+
+	# We need Parse::CPAN::Meta to load the file
+	unless ( eval { require Parse::CPAN::Meta; 1; } ) {
+		return undef;
+	}
+
 	# Merge the perl version into the dependencies
 	my $val  = $self->Meta->{values};
 	my $perl = delete $val->{perl_version};
@@ -558,7 +604,7 @@ sub write_mymeta {
 	}
 
 	# Load the advisory META.yml file
-	my @yaml = YAML::Tiny::LoadFile('META.yml');
+	my @yaml = Parse::CPAN::Meta::LoadFile('META.yml');
 	my $meta = $yaml[0];
 
 	# Overwrite the non-configure dependency hashs
@@ -572,9 +618,7 @@ sub write_mymeta {
 		$meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } };
 	}
 
-	# Save as the MYMETA.yml file
-	print "Writing MYMETA.yml\n";
-	YAML::Tiny::DumpFile('MYMETA.yml', $meta);	
+	return $meta;
 }
 
 1;
@@ -2,12 +2,12 @@
 package Module::Install::Win32;
 
 use strict;
-use Module::Install::Base;
+use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.83';
-	@ISA     = qw{Module::Install::Base};
+	$VERSION = '0.91';
+	@ISA     = 'Module::Install::Base';
 	$ISCORE  = 1;
 }
 
@@ -2,11 +2,11 @@
 package Module::Install::WriteAll;
 
 use strict;
-use Module::Install::Base;
+use Module::Install::Base ();
 
 use vars qw{$VERSION @ISA $ISCORE};
 BEGIN {
-	$VERSION = '0.83';
+	$VERSION = '0.91';;
 	@ISA     = qw{Module::Install::Base};
 	$ISCORE  = 1;
 }
@@ -41,8 +41,18 @@ sub WriteAll {
 
 	# The Makefile write process adds a couple of dependencies,
 	# so write the META.yml files after the Makefile.
-	$self->Meta->write        if $args{meta};
-	$self->Meta->write_mymeta if $self->mymeta;
+	if ( $args{meta} ) {
+		$self->Meta->write;
+	}
+
+	# Experimental support for MYMETA
+	if ( $ENV{X_MYMETA} ) {
+		if ( $ENV{X_MYMETA} eq 'JSON' ) {
+			$self->Meta->write_mymeta_json;
+		} else {
+			$self->Meta->write_mymeta_yaml;
+		}
+	}
 
 	return 1;
 }
@@ -28,7 +28,7 @@ BEGIN {
 	# This is not enforced yet, but will be some time in the next few
 	# releases once we can make sure it won't clash with custom
 	# Module::Install extensions.
-	$VERSION = '0.83';
+	$VERSION = '0.91';
 
 	# Storage for the pseudo-singleton
 	$MAIN    = undef;
@@ -353,7 +353,7 @@ sub _read {
 	if ( $] >= 5.006 ) {
 		open( FH, '<', $_[0] ) or die "open($_[0]): $!";
 	} else {
-		open( FH, "< $_[0]"  ) or die "open($_[0]): $!";	
+		open( FH, "< $_[0]"  ) or die "open($_[0]): $!";
 	}
 	my $string = do { local $/; <FH> };
 	close FH or die "close($_[0]): $!";
@@ -384,7 +384,7 @@ sub _write {
 	if ( $] >= 5.006 ) {
 		open( FH, '>', $_[0] ) or die "open($_[0]): $!";
 	} else {
-		open( FH, "> $_[0]"  ) or die "open($_[0]): $!";	
+		open( FH, "> $_[0]"  ) or die "open($_[0]): $!";
 	}
 	foreach ( 1 .. $#_ ) {
 		print FH $_[$_] or die "print($_[0]): $!";
@@ -9,7 +9,7 @@ use Scalar::Util qw( blessed );
 use Storable qw( dclone );
 use Carp qw( croak );
 
-our $VERSION = '0.05002';
+our $VERSION = '0.06000';
 $VERSION = eval $VERSION;
 
 # sub _compatible_config() is only required as long as we support deprecated
@@ -655,46 +655,46 @@ sub _insert_has_many {
 
 sub _can_insert_new_row {
     my ( $dbic, $form, $config, $repetition, $rel, $pk_field ) = @_;
-
+    
     if ( $config->{new_empty_row} ) {
         # old, deprecated behaviour
-
+        
         my $rows = $config->{new_empty_row};
-
+    
         $rows = [$rows] if ref $rows ne 'ARRAY';
-
+    
         for my $name (@$rows) {
             my ($field)
                 = grep { $_->original_name eq $name } @{ $repetition->get_fields };
-
+    
             return if !defined $field;
-
+    
             my $nested_name = $field->nested_name;
             return if !$form->valid($nested_name);
-
+    
             my $value = $form->param_value($nested_name);
             return if !length $value;
         }
     }
     else {
         # new behaviour
-
+        
         my @rep_fields = @{ $repetition->get_fields };
-
+        
         my $pk_name = $pk_field->nested_name;
-
+        
         my @constraints = grep { $_->when->{field} eq $pk_name }
                           grep { defined $_->when }
                           map { @{ $_->get_constraints({ type => 'Required' }) } }
                             @rep_fields;
-
+        
         my @required_fields;
-
+        
         if ( @constraints ) {
             # if there are any Required constraints whose 'when' clause points to
             # the PK field - check that all these fields are filled in - as
             # the PK value is missing on new reps, so the constraint won't have run
-
+            
             return if
                 notall { defined && length }
                 map { $form->param_value( $_->nested_name ) }
@@ -704,11 +704,11 @@ sub _can_insert_new_row {
         else {
             # otherwise, just check at least 1 field that matches either a column
             # name or an accessor, is filled in
-
+            
             my $result_source = $dbic->$rel->result_source;
-
+            
             #  only create a new record if (read from bottom)...
-
+            
             return if
                 none { defined && length }
                 map { $form->param_value( $_->nested_name ) }
@@ -720,7 +720,7 @@ sub _can_insert_new_row {
                     @rep_fields;
         }
     }
-
+    
     return 1;
 }
 
@@ -746,25 +746,25 @@ sub _delete_has_many {
 
 sub _fix_value {
     my ( $dbic, $col, $value, $field, ) = @_;
-
+    
     my $col_info    = $dbic->column_info($col);
     my $is_nullable = $col_info->{is_nullable} || 0;
     my $data_type   = $col_info->{data_type} || '';
-
+    
     if ( defined $value ) {
         if ( (     $is_nullable
                 || $data_type =~ m/^timestamp|date|int|float|numeric/i
             )
 
             # comparing to '' does not work for inflated objects
-            && !ref $value
+            && !ref $value 
             && $value eq ''
             )
         {
             $value = undef;
         }
     }
-
+    
     if ( !defined $value
         && defined $field
         && $field->isa('HTML::FormFu::Element::Checkbox')
@@ -772,7 +772,7 @@ sub _fix_value {
     {
         $value = 0;
     }
-
+    
     return $value;
 }
 
@@ -781,19 +781,19 @@ sub _save_columns {
 
     for my $field ( @{ $base->get_fields }, ) {
         next if not is_direct_child( $base, $field );
-
+        
         my $config = _compatible_config($field);
         next if $config->{delete_if_true};
         next if $config->{read_only};
-
+        
         my $name = $field->name;
         $name = $field->original_name if $field->original_name;
-
+        
         my $accessor = $config->{accessor} || $name;
         next if not defined $accessor;
-
+        
         my $value = $form->param_value( $field->nested_name );
-
+        
         next if $config->{ignore_if_empty} && ( !defined $value || $value eq "" );
 
         my ($pk) = $dbic->result_source->primary_columns;
@@ -825,7 +825,7 @@ sub _save_columns {
         {
             $dbic->set_column( $accessor, $value );
         }
-        elsif ( $dbic->can($accessor)
+        elsif ( $dbic->can($accessor) 
             # and $accessor is not a has_one or might_have rel where the foreign key is on the foreign table
             and !$dbic->result_source->relationship_info($accessor)) {
             $dbic->$accessor($value);
@@ -847,17 +847,17 @@ sub _save_columns {
     for my $valid ( $form->valid ) {
         next if @{ $base->get_fields( name => $valid ) };
         next if not $dbic->can($valid);
-
+        
         my $value = $form->param_value($valid);
         $dbic->$valid($value);
     }
-
+    
     return 1;
 }
 
 sub _save_multi_value_fields_many_to_many {
     my ( $base, $dbic, $form, $attrs, $rels, $cols ) = @_;
-
+    
     my @fields = grep {
         ( defined $attrs->{nested_base} && defined $_->parent->nested_name )
             ? $_->parent->nested_name eq $attrs->{nested_base}
@@ -883,12 +883,13 @@ sub _save_multi_value_fields_many_to_many {
             my @values = $form->param_list($nested_name);
             my @rows;
 
-            if (@values) {
-                my $config = _compatible_config($field);
+            my $config = _compatible_config($field);
 
-                my ($pk) = $config->{default_column}
-                    || $related->result_source->primary_columns;
+            my ($pk) = $config->{default_column}
+                || $related->result_source->primary_columns;
 
+            if (@values) {
+                
                 $pk = "me.$pk" unless $pk =~ /\./;
 
                 @rows = $related->result_source->resultset->search( {
@@ -896,9 +897,24 @@ sub _save_multi_value_fields_many_to_many {
                         $pk => { -in => \@values } } )->all;
             }
 
-            my $set_method = "set_$name";
-
-            $dbic->$set_method( \@rows );
+            if($config->{additive}) {
+                
+                my $relinfo = $dbic->result_source->relationship_info($name);
+                
+                $pk =~ s/^.*\.//;
+                
+                my $set_method = "add_to_$name";
+                my $remove_method = "remove_from_$name";
+                                
+                foreach my $row ( @rows ) {
+                    $dbic->$remove_method($row);
+                    $dbic->$set_method($row, $config->{link_values});
+                }
+            } else {
+                my $set_method = "set_$name";
+                
+                $dbic->$set_method( \@rows, $config->{link_values} );
+            }
         }
     }
 }
@@ -1050,26 +1066,26 @@ Example of typical use in a Catalyst controller:
 
     sub edit : Chained {
         my ( $self, $c ) = @_;
-
+        
         my $form = $c->stash->{form};
         my $book = $c->stash->{book};
-
+        
         if ( $form->submitted_and_valid ) {
-
+            
             # update dbic row with submitted values from form
-
+            
             $form->model->update( $book );
-
+            
             $c->response->redirect( $c->uri_for('view', $book->id) );
             return;
         }
         elsif ( !$form->submitted ) {
-
+            
             # use dbic row to set form's default values
-
+            
             $form->model->default_values( $book );
         }
-
+        
         return;
     }
 
@@ -1139,7 +1155,7 @@ An example of setting the ResultSet name on a Form:
     ---
     model_config:
       resultset: FooTable
-
+    
     elements:
       # [snip]
 
@@ -1182,20 +1198,20 @@ For the following DBIx::Class schema:
 
     package MySchema::Book;
     use base 'DBIx::Class';
-
+    
     __PACKAGE__->load_components(qw/ Core /);
-
+    
     __PACKAGE__->table("book");
-
+    
     __PACKAGE__->add_columns(
         id     => { data_type => "INTEGER" },
         title  => { data_type => "TEXT" },
         author => { data_type => "TEXT" },
         blurb  => { data_type => "TEXT" },
     );
-
+    
     __PACKAGE__->set_primary_key("id");
-
+    
     1;
 
 A suitable form for this might be:
@@ -1203,18 +1219,18 @@ A suitable form for this might be:
     elements:
       - type: Text
         name: title
-
+      
       - type: Text
         name: author
-
+      
       - type: Textarea
         name: blurb
 
 =head2 might_have and has_one relationships
 
-Set field values from a related row with a C<might_have> or C<has_one>
-relationship by placing the fields within a
-L<Block|HTML::FormFu::Element::Block> (or any element that inherits from
+Set field values from a related row with a C<might_have> or C<has_one> 
+relationship by placing the fields within a 
+L<Block|HTML::FormFu::Element::Block> (or any element that inherits from 
 Block, such as L<Fieldset|HTML::FormFu::Element::Fieldset>) with its
 L<HTML::FormFu/nested_name> set to the relationship name.
 
@@ -1222,40 +1238,40 @@ For the following DBIx::Class schemas:
 
     package MySchema::Book;
     use base 'DBIx::Class';
-
+    
     __PACKAGE__->load_components(qw/ Core /);
-
+    
     __PACKAGE__->table("book");
-
+    
     __PACKAGE__->add_columns(
         id    => { data_type => "INTEGER" },
         title => { data_type => "TEXT" },
     );
-
+    
     __PACKAGE__->set_primary_key("id");
-
+    
     __PACKAGE__->might_have( review => 'MySchema::Review', 'book' );
-
+    
     1;
 
 
     package MySchema::Review;
     use base 'DBIx::Class';
-
+    
     __PACKAGE__->load_components(qw/ Core /);
-
+    
     __PACKAGE__->table("review");
-
+    
     __PACKAGE__->add_columns(
         id          => { data_type => "INTEGER" },
         book        => { data_type => "INTEGER", is_nullable => 1 },
         review_text => { data_type => "TEXT" },
     );
-
+    
     __PACKAGE__->set_primary_key("book");
-
+    
     __PACKAGE__->belongs_to( book => 'MySchema::Book' );
-
+    
     1;
 
 A suitable form for this would be:
@@ -1263,7 +1279,7 @@ A suitable form for this would be:
     elements:
       - type: Text
         name: title
-
+      
       - type: Block
         nested_name: review
         elements:
@@ -1275,20 +1291,20 @@ to have a field for the related table's primary key, as DBIx::Class will
 handle retrieving the correct row automatically.
 
 You can also set a C<has_one> or C<might_have> relationship using a multi value
-field like L<Select|HTML::FormFu::Element::Select>.
+field like L<Select|HTML::FormFu::Element::Select>. 
 
     elements:
       - type: Text
         name: title
-
+      
       - type: Select
         nested: review
         model_config:
           resultset: Review
 
 This will load all reviews into the select field. If you select a review from
-that list, a current relationship to a review is removed and the new one is
-added. This requires that the primary key of the C<Review> table and the
+that list, a current relationship to a review is removed and the new one is 
+added. This requires that the primary key of the C<Review> table and the 
 foreign key do not match.
 
 =head2 has_many and many_to_many relationships
@@ -1313,45 +1329,45 @@ outside of the Repeatable block.
 This field is used to store a count of the number of repetitions of the
 Repeatable block were created.
 When the form is submitted, this value is used during C<< $form->process >>
-to ensure the form is rebuild with the correct number of repetitions.
+to ensure the form is rebuilt with the correct number of repetitions.
 
 For the following DBIx::Class schemas:
 
     package MySchema::Book;
     use base 'DBIx::Class';
-
+    
     __PACKAGE__->load_components(qw/ Core /);
-
+    
     __PACKAGE__->table("book");
-
+    
     __PACKAGE__->add_columns(
         id    => { data_type => "INTEGER" },
         title => { data_type => "TEXT" },
     );
-
+    
     __PACKAGE__->set_primary_key("id");
-
+    
     __PACKAGE__->has_many( review => 'MySchema::Review', 'book' );
-
+    
     1;
 
 
     package MySchema::Review;
     use base 'DBIx::Class';
-
+    
     __PACKAGE__->load_components(qw/ Core /);
-
+    
     __PACKAGE__->table("review");
-
+    
     __PACKAGE__->add_columns(
         book        => { data_type => "INTEGER" },
         review_text => { data_type => "TEXT" },
     );
-
+    
     __PACKAGE__->set_primary_key("book");
-
+    
     __PACKAGE__->belongs_to( book => 'MySchema::Book' );
-
+    
     1;
 
 A suitable form for this would be:
@@ -1359,29 +1375,29 @@ A suitable form for this would be:
     elements:
       - type: Text
         name: title
-
+      
       - type: Hidden
         name: review_count
-
+      
       - type: Repeatable
         nested_name: review
         counter_name: review_count
         elements:
           - type: Hidden
             name: book
-
+          
           - type: Textarea
             name: review_text
 
 =head2 many_to_many selection
 
 To select / deselect rows from a C<many_to_many> relationship, you must use
-a multi-valued element, such as a
+a multi-valued element, such as a 
 L<Checkboxgroup|HTML::FormFu::Element::Checkboxgroup> or a
-L<Select|HTML::FormFu::Element::Select> with
+L<Select|HTML::FormFu::Element::Select> with 
 L<multiple|HTML::FormFu::Element::Select/multiple> set.
 
-The field's L<name|HTML::FormFu::Element::_Field/name> must be set to the
+The field's L<name|HTML::FormFu::Element::_Field/name> must be set to the 
 name of the C<many_to_many> relationship.
 
 =item default_column
@@ -1396,6 +1412,34 @@ primary key, set C<< $field->model_config->{default_column} >>.
           model_config:
             default_column: foo
 
+If you want to set columns on the link table you can do so if you add a 
+C<link_values> attribute to C<model_config>:
+
+    ---
+    element:
+        - type: Checkboxgroup
+          name: authors
+          model_config:
+            link_values:
+              foo: bar
+
+
+The default implementation will first remove all related objects and set the
+new ones (see L<http://search.cpan.org/perldoc?DBIx::Class::Relationship::Base#set_$rel>).
+If you want to add the selected objects to the current set of objects
+set C<additive> in the C<model_config>.
+
+    ---
+    element:
+        - type: Checkboxgroup
+          name: authors
+          model_config:
+            additive: 1
+            options_from_model: 0
+
+(<options_from_model> is set to C<0> because this L</options_from_model> will try to fetch
+all objects from the result class C<Authors> if C<model_config> is specified
+without a C<resultset> attribute.)
 
 =head1 COMMON ARGUMENTS
 
@@ -1453,39 +1497,39 @@ For the following DBIx::Class schemas:
 
     package MySchema::Book;
     use base 'DBIx::Class';
-
+    
     __PACKAGE__->load_components(qw/ Core /);
-
+    
     __PACKAGE__->table("book");
-
+    
     __PACKAGE__->add_columns(
         id    => { data_type => "INTEGER" },
         title => { data_type => "TEXT" },
     );
-
+    
     __PACKAGE__->set_primary_key("id");
-
+    
     __PACKAGE__->might_have( review => 'MySchema::Review', 'book' );
-
+    
     1;
 
 
     package MySchema::Review;
     use base 'DBIx::Class';
-
+    
     __PACKAGE__->load_components(qw/ Core /);
-
+    
     __PACKAGE__->table("review");
-
+    
     __PACKAGE__->add_columns(
         book        => { data_type => "INTEGER" },
         review_text => { data_type => "TEXT" },
     );
-
+    
     __PACKAGE__->set_primary_key("book");
-
+    
     __PACKAGE__->belongs_to( book => 'MySchema::Book' );
-
+    
     1;
 
 A suitable form for this would be:
@@ -1493,7 +1537,7 @@ A suitable form for this would be:
     elements:
       - type: Text
         name: title
-
+      
       - type: Block
         nested_name: review
         elements:
@@ -1526,20 +1570,20 @@ An example of use might be:
     elements:
       - type: Text
         name: title
-
+      
       - type: Hidden
         name: review_count
-
+      
       - type: Repeatable
         nested_name: review
         counter_name: review_count
         elements:
           - type: Hidden
             name: book
-
+          
           - type: Textarea
             name: review_text
-
+          
           - type: Checkbox
             name: delete_review
             label: 'Delete Review?'
@@ -1564,6 +1608,11 @@ block.
 
 =item new_rows_max
 
+Set to the maximum number of new rows that a Repeatable block is allowed to
+add.
+
+If not set, it will fallback to the value of C<empty_rows>.
+
 =back
 
 =head2 Config options for options_from_model
@@ -1617,13 +1666,13 @@ L<DBIx::Class::ResultSet/search>.
 
 =head2 Add extra values not in the form
 
-To update values to the database which weren't submitted to the form,
+To update values to the database which weren't submitted to the form, 
 you can first add them to the form with L<add_valid|HTML::FormFu/add_valid>.
 
     my $passwd = generate_passwd();
-
+    
     $form->add_valid( passwd => $passwd );
-
+    
     $form->model->update( $row );
 
 C<add_valid> works for fieldnames that don't exist in the form.
@@ -1634,7 +1683,7 @@ You can make a field read only. The value of such fields cannot be changed by
 the user even if they submit a value for it.
 
   $field->model_config->{read_only} = 1;
-
+  
   - Name: field
     model_config:
       read_only: 1
@@ -1655,7 +1704,7 @@ See C<empty_rows> in L</"Config options for Repeatable blocks"> instead.
 Is deprecated and provided only for backwards compatability.
 Will be removed at some point in the future.
 
-See C<empty_rows> in L</"Config options for Repeatable blocks"> instead.
+See C<new_rows_max> in L</"Config options for Repeatable blocks"> instead.
 
 =head2 Range constraint
 
@@ -1669,12 +1718,12 @@ See C<empty_rows> in L</"Config options for Repeatable blocks"> instead.
 
 =head1 CAVEATS
 
-To ensure your column's inflators and deflators are called, we have to
-get / set values using their named methods, and not with C<get_column> /
+To ensure your column's inflators and deflators are called, we have to 
+get / set values using their named methods, and not with C<get_column> / 
 C<set_column>.
 
-Because of this, beware of having column names which clash with DBIx::Class
-built-in method-names, such as C<delete>. - It will have obviously
+Because of this, beware of having column names which clash with DBIx::Class 
+built-in method-names, such as C<delete>. - It will have obviously 
 undesirable results!
 
 =head1 SUPPORT
@@ -1693,23 +1742,23 @@ L<http://lists.scsys.co.uk/pipermail/html-formfu/>
 
 =head1 BUGS
 
-Please submit bugs / feature requests to
-L<http://code.google.com/p/html-formfu/issues/list> (preferred) or
+Please submit bugs / feature requests to 
+L<http://code.google.com/p/html-formfu/issues/list> (preferred) or 
 L<http://rt.perl.org>.
 
 =head1 SUBVERSION REPOSITORY
 
-The publicly viewable subversion code repository is at
+The publicly viewable subversion code repository is at 
 L<http://html-formfu.googlecode.com/svn/trunk/HTML-FormFu-Model-DBIC>.
 
-If you wish to contribute, you'll need a GMAIL email address. Then just
+If you wish to contribute, you'll need a GMAIL email address. Then just 
 ask on the mailing list for commit access.
 
-If you wish to contribute but for some reason really don't want to sign up
-for a GMAIL account, please post patches to the mailing list (although
-you'll have to wait for someone to commit them).
+If you wish to contribute but for some reason really don't want to sign up 
+for a GMAIL account, please post patches to the mailing list (although  
+you'll have to wait for someone to commit them). 
 
-If you have commit permissions, use the HTTPS repository url:
+If you have commit permissions, use the HTTPS repository url: 
 L<https://html-formfu.googlecode.com/svn/trunk/HTML-FormFu-Model-DBIC>
 
 =head1 SEE ALSO
@@ -1735,7 +1784,7 @@ Mario Minati
 
 Copyright (C) 2007 by Carl Franks
 
-Based on the original source code of L<DBIx::Class::HTMLWidget>, copyright
+Based on the original source code of L<DBIx::Class::HTMLWidget>, copyright 
 Thomas Klausner.
 
 This library is free software; you can redistribute it and/or modify
@@ -4,16 +4,14 @@ use Test::More tests => 6;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/create/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 # put schema on form stash
 $form->stash->{schema} = $schema;
@@ -4,16 +4,14 @@ use Test::More tests => 25;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 25;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/basic_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/belongs_to_lookup_table.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/belongs_to_lookup_table_combobox.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/empty_rows_zero.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 1;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_many_combobox.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 8;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_many_repeatable.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 18;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_many_repeatable_delete_true.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 10;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_many_repeatable_label.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 12;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_many_repeatable_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 12;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 1;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_one.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/has_one_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/label.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 22;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/many_to_many-has_many.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+use HTML::FormFu;
+use lib 't/lib';
+use DBICTestLib 'new_schema';
+use MySchema;
+
+my $form = HTML::FormFu->new;
+
+$form->load_config_file('t/default_values/many_to_many_checkboxgroup.yml');
+
+my $schema = new_schema();
+
+my $master = $schema->resultset('Master')->create({ id => 1 });
+
+# filler
+
+{
+    $master->create_related( 'user', { name => 'John', } );
+
+    $master->create_related( 'user', { name => 'Ringo', } );
+
+    my $user3 = $master->create_related( 'user', { name => 'George', } );
+
+    $user3->add_to_bands( { band => 'the kinks', } );
+}
+
+# row we're going to use
+
+{
+    my $paul = $master->create_related( 'user', { name => 'Paul', } );
+
+    $paul->add_to_bands( { band => 'the beatles', } );
+
+    $paul->add_to_bands( { band => 'wings', } );
+}
+
+{
+    my $row = $schema->resultset('User')->find(4);
+
+    $form->model->default_values($row);
+
+    is( $form->get_field('id')->default,   4 );
+    is( $form->get_field('name')->default, 'Paul' );
+
+    is_deeply( $form->get_field('bands')->default, [ 2, 3 ] );
+}
+
@@ -0,0 +1,15 @@
+---
+auto_fieldset: 1
+
+elements:
+  - type: Hidden
+    name: id
+  
+  - type: Text
+    name: name
+  
+  - type: Checkboxgroup
+    name: bands
+  
+  - type: Submit
+    name: submit
@@ -4,16 +4,14 @@ use Test::More tests => 10;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/many_to_many_repeatable.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,17 +4,15 @@ use Test::More tests => 16;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file(
     't/default_values/many_to_many_repeatable_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,17 +4,15 @@ use Test::More tests => 12;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file(
     't/default_values/many_to_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/many_to_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/many_to_many_select_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 1;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/methods.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/might_have.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs      = $schema->resultset('Master');
 my $note_rs = $schema->resultset('Note');
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/might_have.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs      = $schema->resultset('Master');
 my $note_rs = $schema->resultset('Note');
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/multi_label.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/nested_name_accessor.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/opt_accessor.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/opt_accessor_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 26;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 26;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/basic_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/belongs_to_lookup_table.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/has_many_repeatable.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 13;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/has_many_repeatable_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 11;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/has_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/has_one.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/has_one_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 11;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/many_to_many_repeatable.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,17 +4,15 @@ use Test::More tests => 17;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file(
     't/deprecated-defaults_from_model/many_to_many_repeatable_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,17 +4,15 @@ use Test::More tests => 13;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file(
     't/deprecated-defaults_from_model/many_to_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/many_to_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/many_to_many_select_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/methods.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/might_have.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs      = $schema->resultset('Master');
 my $note_rs = $schema->resultset('Note');
@@ -4,16 +4,14 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/might_have.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs      = $schema->resultset('Master');
 my $note_rs = $schema->resultset('Note');
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/opt_accessor.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/opt_accessor_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 10;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-new_empty_row/default_values/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,17 +4,15 @@ use Test::More tests => 12;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file(
     't/deprecated-new_empty_row/default_values/many_to_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-new_empty_row/update/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,17 +4,15 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 use DateTime;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-new_empty_row/update/has_many_repeatable_new_date.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master_rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-new_empty_row/update/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 8;
 
 use HTML::FormFu;
 use lib qw(t/lib lib);
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-new_empty_row_multi/update/has_many_repeatable_many_new.yml');
 
-my $schema     = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema     = new_schema();
 my $user_rs    = $schema->resultset('User');
 my $address_rs = $schema->resultset('Address');
 
@@ -4,16 +4,14 @@ use Test::More tests => 8;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-defaults_from_model/belongs_to_lookup_table.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/column_without_field.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 8;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/has_many_repeatable.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 6;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/has_many_repeatable_delete_true.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 10;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 8;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/has_one.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/has_one.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/has_one_no_id.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 10;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/many_to_many_repeatable.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')-> create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 6;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/many_to_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')-> create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/many_to_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')-> create({ id => 1 });
 
@@ -4,13 +4,11 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
 
-
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 {
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/might_have.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/might_have.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs      = $schema->resultset('Master');
 my $note_rs = $schema->resultset('Note');
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/might_have_delete_if_empty.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs      = $schema->resultset('Master');
 my $note_rs = $schema->resultset('Note');
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/opt_accessor.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/opt_accessor_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/deprecated-save_to_model/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -6,167 +6,20 @@ use DBI;
 
 use base 'Exporter';
 
-our @EXPORT_OK = qw/ new_db /;
+our @EXPORT_OK = qw/ new_schema /;
 
-END {
-    if ( -f 't/test.db') {
-        unlink 't/test.db';
-    }
-}
-
-sub output_html {
-    my ($form) = @_;
-    
-    open my $fh, '>', 'out.html'
-        or die $!;
+sub new_schema {
+    my $schema = MySchema->connect('dbi:SQLite:dbname=:memory:');
     
-    print $fh <<HTML;
-<html>
-<body>
-$form
-</body>
-</html>
-HTML
-}
-
-sub new_db {
+    $schema->deploy;
     
-    if ( -f 't/test.db' ) {
-        unlink 't/test.db'
-            or die $!;
-    }
+    $schema->resultset('Type')->create({ id => 1, type => 'foo' });
+    $schema->resultset('Type')->create({ id => 2, type => 'bar' });
     
-    my $dbh = DBI->connect(
-        'dbi:SQLite:dbname=t/test.db',
-        {
-            RaiseError => 1,
-            AutoCommit => 1,
-        });
+    $schema->resultset('Type2')->create({ id => 1, type => 'foo' });
+    $schema->resultset('Type2')->create({ id => 2, type => 'bar' });
     
-    $dbh->do( <<SQL );
-CREATE TABLE master (
-  id             INTEGER PRIMARY KEY NOT NULL,
-  text_col       TEXT,
-  password_col   TEXT,
-  checkbox_col   BOOLEAN DEFAULT 1,
-  select_col     TEXT,
-  combobox_col   TEXT,
-  radio_col      TEXT,
-  radiogroup_col TEXT,
-  date_col       DATETIME,
-  type_id        INTEGER,
-  type2_id       INTEGER,
-  not_in_form    TEXT
-);
-
-SQL
-
-
-    $dbh->do( <<SQL );
-CREATE TABLE note (
-  id     INTEGER PRIMARY KEY NOT NULL,
-  master INTEGER NOT NULL,
-  note   TEXT NOT NULL
-);
-
-SQL
-
-
-    $dbh->do( <<SQL );
-CREATE TABLE user (
-  id     INTEGER PRIMARY KEY NOT NULL,
-  master INTEGER,
-  name   TEXT NOT NULL,
-  title  TEXT
-);
-
-SQL
-
-
-    $dbh->do( <<SQL );
-CREATE TABLE band (
-  id   INTEGER PRIMARY KEY NOT NULL,
-  manager INTEGER,
-  band TEXT NOT NULL
-);
-
-SQL
-
-
-    $dbh->do( <<SQL );
-CREATE TABLE user_band (
-  user INTEGER NOT NULL,
-  band INTEGER NOT NULL,
-  PRIMARY KEY (user, band)
-);
-
-SQL
-
-
-    $dbh->do( <<SQL );
-CREATE TABLE address (
-  id       INTEGER PRIMARY KEY NOT NULL,
-  user     INTEGER NOT NULL,
-  my_label TEXT,
-  address  TEXT NOT NULL
-);
-
-SQL
-
-
-    $dbh->do( <<SQL );
-CREATE TABLE type (
-  id   INTEGER PRIMARY KEY NOT NULL,
-  type TEXT NOT NULL
-);
-
-SQL
-
-    $dbh->do(" INSERT INTO type VALUES (1,'foo')" );;
-    $dbh->do(" INSERT INTO type VALUES (2,'bar')" );
-
-
-    $dbh->do( <<SQL );
-CREATE TABLE type2 (
-  id   INTEGER PRIMARY KEY NOT NULL,
-  type TEXT NOT NULL
-);
-
-SQL
-
-    $dbh->do("INSERT INTO type2 VALUES (1,'foo')" );
-    $dbh->do("INSERT INTO type2 VALUES (2,'bar')" );
-
-
-    $dbh->do( <<SQL );
-CREATE TABLE has_many (
-  user  INTEGER NOT NULL,
-  key   TEXT NOT NULL,
-  value TEXT NOT NULL,
-  PRIMARY KEY (user, key)
-);
-
-SQL
-
-    $dbh->do( <<SQL );
-CREATE TABLE schedule (
-  id     INTEGER PRIMARY KEY NOT NULL,
-  master INTEGER NOT NULL,
-  date   DATETIME NOT NULL,
-  note   TEXT NOT NULL
-);
-
-SQL
-
-    $dbh->do( <<SQL );
-CREATE TABLE manager (
-  id   INTEGER PRIMARY KEY NOT NULL,
-  name TEXT NOT NULL
-);
-
-SQL
-
+    return $schema;
 }
 
-
 1;
@@ -11,7 +11,7 @@ __PACKAGE__->table("address");
 __PACKAGE__->add_columns(
     id        => { data_type => "INTEGER", is_nullable => 0 },
     user      => { data_type => "INTEGER", is_nullable => 0 },
-    my_label  => { data_type => "TEXT" },
+    my_label  => { data_type => "TEXT", is_nullable => 1 },
     address   => { data_type => "TEXT", is_nullable => 0 },
 );
 
@@ -10,7 +10,7 @@ __PACKAGE__->table("band");
 
 __PACKAGE__->add_columns(
     id      => { data_type => "INTEGER", is_nullable => 0 },
-    manager => { data_type => "INTEGER" },
+    manager => { data_type => "INTEGER", is_nullable => 1 },
     band    => { data_type => "TEXT", is_nullable => 0 },
 );
 
@@ -15,21 +15,21 @@ __PACKAGE__->add_columns(
         data_type => "INTEGER",
         is_nullable => 0,
     },
-    text_col       => { data_type => "TEXT" },
-    password_col   => { data_type => "TEXT" },
+    text_col       => { data_type => "TEXT", is_nullable => 1 },
+    password_col   => { data_type => "TEXT", is_nullable => 1 },
     checkbox_col   => {
         data_type => "BOOLEAN",
         default_value => 1,
         is_nullable   => 0,
     },
-    select_col     => { data_type => "TEXT" },
-    combobox_col   => { data_type => "TEXT" },
-    radio_col      => { data_type => "TEXT" },
-    radiogroup_col => { data_type => "TEXT" },
-    date_col       => { data_type => "DATETIME" },
-    type_id        => { data_type => "INTEGER" },
-    type2_id       => { data_type => "INTEGER" },
-    not_in_form    => { data_type => "TEXT" },
+    select_col     => { data_type => "TEXT", is_nullable => 1 },
+    combobox_col   => { data_type => "TEXT", is_nullable => 1 },
+    radio_col      => { data_type => "TEXT", is_nullable => 1 },
+    radiogroup_col => { data_type => "TEXT", is_nullable => 1 },
+    date_col       => { data_type => "DATETIME", is_nullable => 1 },
+    type_id        => { data_type => "INTEGER", is_nullable => 1 },
+    type2_id       => { data_type => "INTEGER", is_nullable => 1 },
+    not_in_form    => { data_type => "TEXT", is_nullable => 1 },
 );
 
 __PACKAGE__->set_primary_key("id");
@@ -19,5 +19,7 @@ __PACKAGE__->set_primary_key("id");
 
 __PACKAGE__->belongs_to( master => 'MySchema::Master' );
 
+__PACKAGE__->has_many( tasks => 'MySchema::Task', 'schedule' );
+
 1;
 
@@ -0,0 +1,23 @@
+package MySchema::Task;
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components(qw/ Core /);
+
+__PACKAGE__->table("task");
+
+__PACKAGE__->add_columns(
+    id       => { data_type => "INTEGER", is_nullable => 0 },
+    schedule => { data_type => "INTEGER", is_nullable => 0 },
+    deadline => { data_type => "DATETIME", is_nullable => 1 },
+    detail   => { data_type => "TEXT", is_nullable => 0 },
+);
+
+__PACKAGE__->set_primary_key("id");
+
+__PACKAGE__->belongs_to( schedule => 'MySchema::Schedule' );
+
+1;
+
@@ -0,0 +1,22 @@
+package MySchema::TwoNote;
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components(qw/ Core /);
+
+__PACKAGE__->table("two_note");
+
+__PACKAGE__->add_columns(
+    id     => { data_type => "INTEGER", is_nullable => 0 },
+    two_note_id => { data_type => "INTEGER", is_nullable => 0 },
+    note   => { data_type => "TEXT", is_nullable => 0 },
+);
+
+__PACKAGE__->set_primary_key("two_note_id");
+
+__PACKAGE__->belongs_to( id => 'MySchema::Master', { id => 'id' } );
+
+1;
+
@@ -12,7 +12,7 @@ __PACKAGE__->add_columns(
     id     => { data_type => "INTEGER", is_nullable => 0 },
     master => { data_type => "INTEGER", is_nullable => 1 },
     name   => { data_type => "TEXT", is_nullable => 0 },
-    title  => { data_type => "TEXT" },
+    title  => { data_type => "TEXT", is_nullable => 1 },
 );
 
 __PACKAGE__->set_primary_key("id");
@@ -17,6 +17,10 @@ __PACKAGE__->add_columns(
         data_type   => "INTEGER",
         is_nullable => 0,
     },
+    rating => {
+        data_type => "INTEGER",
+        is_nullable => 1,
+    }
 );
 
 __PACKAGE__->set_primary_key( "user", "band" );
@@ -4,15 +4,13 @@ use Test::More tests => 8;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/belongs_to.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,15 +4,13 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/belongs_to_combobox.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,15 +4,13 @@ use Test::More tests => 1;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/belongs_to_config_zero.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,15 +4,13 @@ use Test::More tests => 1;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/belongs_to_config_zero_combobox.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,15 +4,13 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/belongs_to_localize_label.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,15 +4,13 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/condition_from_stash.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,15 +4,13 @@ use Test::More tests => 6;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/condition_from_stash_combobox.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,15 +4,13 @@ use Test::More tests => 11;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/constraint_autoset.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,16 +4,14 @@ use Test::More tests => 34;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/has_many_repeatable_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash( { schema => $schema } );
 
@@ -4,17 +4,15 @@ use Test::More tests => 1;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use HTMLFormFu::MockContext;
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/options_from_model/many_to_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $context = HTMLFormFu::MockContext->new( {
     model => $schema->resultset('Band'),
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 8;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/belongs_to_lookup_table.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/belongs_to_lookup_table_combobox.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -1,35 +1,62 @@
 use strict;
 use warnings;
-use Test::More tests => 2;
+use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
-my $form = HTML::FormFu->new;
-
-$form->load_config_file('t/update/belongs_to_select.yml');
-
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
-
-$form->stash->{schema} = $schema;
-
-my $rs = $schema->resultset('Master');
-
-$rs->create( { id => 1 } );
-$rs->create( { id => 2 } );
-
-my $master = $rs->create( { text_col => 'b', type_id => 2, type2_id => 2 } );
-
-$form->process( { master => 2, note => 'foo' } );
-
-$form->model->create;
-
-my $note = $schema->resultset("Note")->find(1);
-
-is($note->master->id, 2);
-
-is($note->note, 'foo');
+{
+    my $form = HTML::FormFu->new;
+    
+    $form->load_config_file('t/update/belongs_to_select.yml');
+    
+    my $schema = new_schema();
+    
+    $form->stash->{schema} = $schema;
+    
+    my $rs = $schema->resultset('Master');
+    
+    $rs->create( { id => 1 } );
+    $rs->create( { id => 2 } );
+    
+    my $master = $rs->create( { text_col => 'b', type_id => 2, type2_id => 2 } );
+    
+    $form->process( { master => 2, note => 'foo' } );
+    
+    $form->model->create;
+    
+    my $note = $schema->resultset("Note")->find(1);
+    
+    is($note->master->id, 2);
+    
+    is($note->note, 'foo');
+}
+
+{
+    my $form = HTML::FormFu->new;
+    
+    $form->load_config_file('t/update/belongs_to_select_two.yml');
+    
+    my $schema = new_schema();
+    
+    $form->stash->{schema} = $schema;
+    
+    my $rs = $schema->resultset('Master');
+    
+    $rs->create( { id => 4 } );
+    $rs->create( { id => 5 } );
+    
+    my $master = $rs->create( { text_col => 'b', type_id => 2, type2_id => 2 } );
+    
+    $form->process( { id => 4, note => 'foo' } );
+    
+    $form->model->create;
+    
+    my $note = $schema->resultset("TwoNote")->find(1);
+    
+    is($note->id->id, 4);
+    
+    is($note->note, 'foo');
+}
@@ -0,0 +1,8 @@
+---
+  model_config:
+    resultset: TwoNote
+  elements:
+    - name: two_note_id
+    - name: note
+    - name: id
+      type: Select
\ No newline at end of file
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/column_without_field.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_delete_true.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib qw(t/lib lib);
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_many_new.yml');
 
-my $schema     = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema     = new_schema();
 my $user_rs    = $schema->resultset('User');
 my $address_rs = $schema->resultset('Address');
 
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib qw(t/lib lib);
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_many_new.yml');
 
-my $schema     = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema     = new_schema();
 my $user_rs    = $schema->resultset('User');
 my $address_rs = $schema->resultset('Address');
 
@@ -4,16 +4,14 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,17 +4,15 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 use DateTime;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_new_date.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master_rs = $schema->resultset('Master');
 
@@ -4,11 +4,9 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_new_dependon.yml');
@@ -19,7 +17,7 @@ $form->load_config_file('t/update/has_many_repeatable_new_dependon.yml');
 # test a DependOn constraint attached to the PK column
 # with 'others' listing the required fields
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,18 +4,16 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_new_implicit.yml');
 
 # config file doesn't set 'new_rows_max' so 'empty_rows' is used instead
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,11 +4,9 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_many_repeatable_new_required_when.yml');
@@ -19,7 +17,7 @@ $form->load_config_file('t/update/has_many_repeatable_new_required_when.yml');
 # test using a Required constraint 
 # with 'when' pointing to the PK field
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_one.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_one.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 4;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_one_no_id.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/has_one_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 $form->stash->{schema} = $schema;
 
@@ -4,16 +4,14 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/ignore_if_empty.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('User')->create( {
         master => 1,
@@ -4,16 +4,14 @@ use Test::More tests => 15;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/many_to_many-has_many.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create( { id => 1 } );
 
@@ -0,0 +1,75 @@
+use strict;
+use warnings;
+use Test::More tests => 5;
+
+use HTML::FormFu;
+use lib 't/lib';
+use DBICTestLib 'new_schema';
+use MySchema;
+
+my $form = HTML::FormFu->new;
+
+$form->load_config_file('t/update/many_to_many_checkboxgroup.yml');
+
+my $schema = new_schema();
+
+my $master = $schema->resultset('Master')-> create({ id => 1 });
+
+my $band1;
+
+# filler rows
+{
+    # user 1
+    my $u1 = $master->create_related( 'user', { name => 'John' } );
+
+    # band 1
+    $band1 = $u1->add_to_bands({ band => 'the beatles' });
+}
+
+# rows we're going to use
+{
+    # user 2
+    my $u2 = $master->create_related( 'user', { name => 'Paul', } );
+
+    # band 2
+    $u2->add_to_bands({ band => 'wings' });
+    
+    # band 3 - not used
+    $schema->resultset('Band')->create({ band => 'the kinks' });
+    
+    # band 1
+    $u2->add_to_bands($band1);
+}
+
+# currently,
+# user [2] => bands [2, 1]
+
+{
+    $form->process( {
+            id    => 2,
+            name  => 'Paul McCartney',
+            bands => [ 1, 3 ],
+        } );
+
+    ok( $form->submitted_and_valid );
+
+    my $row = $schema->resultset('User')->find(2);
+
+    $form->model->update($row);
+}
+
+{
+    my $row = $schema->resultset('User')->find(2);
+    
+    is( $row->name, 'Paul McCartney' );
+
+    my @bands = $row->bands->all;
+
+    is( scalar @bands, 2 );
+
+    my @id = sort map { $_->id } @bands;
+
+    is( $id[0], 1 );
+    is( $id[1], 3 );
+}
+
@@ -0,0 +1,15 @@
+---
+auto_fieldset: 1
+
+elements:
+  - type: Hidden
+    name: id
+  
+  - type: Text
+    name: name
+  
+  - type: Checkboxgroup
+    name: bands
+  
+  - type: Submit
+    name: submit
@@ -0,0 +1,71 @@
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+use HTML::FormFu;
+use lib 't/lib';
+use DBICTestLib 'new_schema';
+use MySchema;
+
+my $form = HTML::FormFu->new;
+
+$form->load_config_file('t/update/many_to_many_checkboxgroup.yml');
+
+my $schema = new_schema();
+
+my $master = $schema->resultset('Master')-> create({ id => 1 });
+
+my $band1;
+
+# filler rows
+{
+    # user 1
+    my $u1 = $master->create_related( 'user', { name => 'John' } );
+
+    # band 1
+    $band1 = $u1->add_to_bands({ band => 'the beatles' });
+}
+
+# rows we're going to use
+{
+    # user 2
+    my $u2 = $master->create_related( 'user', { name => 'Paul', } );
+
+    # band 2
+    $u2->add_to_bands({ band => 'wings' });
+    
+    # band 3 - not used
+    $schema->resultset('Band')->create({ band => 'the kinks' });
+    
+    # band 1
+    $u2->add_to_bands($band1);
+}
+
+# currently,
+# user [2] => bands [2, 1]
+
+{
+    $form->process( {
+            id    => 2,
+            name  => 'Paul McCartney',
+            # no bands - if you unselect all options,
+            # the browser doesn't submit that param at all
+        } );
+
+    ok( $form->submitted_and_valid );
+
+    my $row = $schema->resultset('User')->find(2);
+
+    $form->model->update($row);
+}
+
+{
+    my $row = $schema->resultset('User')->find(2);
+    
+    is( $row->name, 'Paul McCartney' );
+
+    my @bands = $row->bands->all;
+
+    is( scalar(@bands), 0 );
+}
+
@@ -4,16 +4,14 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/many_to_many_repeatable.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')-> create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 9;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/many_to_many_repeatable_new.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')-> create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 5;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/many_to_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')-> create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/many_to_many_select.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')-> create({ id => 1 });
 
@@ -4,13 +4,11 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
 
-
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 {
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/might_have.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/might_have.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs      = $schema->resultset('Master');
 my $note_rs = $schema->resultset('Note');
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/might_have_delete_if_empty.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs      = $schema->resultset('Master');
 my $note_rs = $schema->resultset('Note');
@@ -4,16 +4,14 @@ use Test::More tests => 7;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,16 +4,14 @@ use Test::More tests => 2;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/default_values/nested_name_accessor.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -0,0 +1,76 @@
+use strict;
+use warnings;
+use Test::More tests => 7;
+
+use HTML::FormFu;
+use lib 't/lib';
+use DBICTestLib 'new_schema';
+use MySchema;
+
+my $form = HTML::FormFu->new;
+
+$form->load_config_file('t/update/nested_repeatable_write.yml');
+
+my $schema = new_schema();
+
+my $master = $schema->resultset('Master')->create({ id => 1 });
+
+# first sub-record
+{
+    # schedule 1
+    my $u1 = $master->create_related( 'schedules', { note => 'some appointment',
+                                                     date => '02-02-2009' } );
+
+    # task 1
+    $u1->create_related( 'tasks' => { detail => 'associated to do item' } );
+}
+
+# second sub-record
+{
+    # schedule 2
+    my $u2 = $master->create_related( 'schedules', { note => 'some other appointment',
+                                                     date => '03-03-2009' } );
+
+    # task 2
+    $u2->create_related( 'tasks', { detail => 'action item 1' } );
+
+    # task 3
+    $u2->create_related( 'tasks', { detail => 'action item 2' } );
+}
+
+{
+    $form->process( {
+            'sched_count'                 => 2,
+            'schedules_2.id'              => 2,
+            'schedules_2.note'            => 'new appointment',
+            'schedules_2.count'           => 2,
+            'schedules_2.tasks_1.id'      => 2,
+            'schedules_2.tasks_1.detail'  => 'new action item 1',
+            'schedules_2.tasks_2.id'      => 3,
+            'schedules_2.tasks_2.detail'  => 'new action item 2',
+        } );
+
+    ok( $form->submitted_and_valid );
+
+    my $row = $schema->resultset('Master')->find(1);
+
+    $form->model->update($row);
+}
+
+{
+    my $schedule = $schema->resultset('Schedule')->find(2);
+
+    is( $schedule->note, 'new appointment' );
+
+    my @add = $schedule->tasks->all;
+
+    is( scalar @add, 2 );
+
+    is( $add[0]->id,      2 );
+    is( $add[0]->detail, 'new action item 1' );
+
+    is( $add[1]->id,      3 );
+    is( $add[1]->detail, 'new action item 2' );
+
+}
+
@@ -0,0 +1,38 @@
+---
+auto_fieldset: 1
+
+elements:
+- type: Hidden
+  name: id
+
+- type: Hidden
+  name: sched_count
+
+- type: Repeatable
+  nested_name: schedules
+  counter_name: sched_count
+  elements:
+
+  - type: Hidden
+    name: id
+
+  - type: Text
+    name: note
+
+  - type: Hidden
+    name: count
+
+  - type: Repeatable
+    nested_name: tasks
+    counter_name: count
+
+    elements:
+      - type: Hidden
+        name: id
+
+      - type: Text
+        name: detail
+
+- type: Submit
+  name: submit
+
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/opt_accessor.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/opt_accessor_nested.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $master = $schema->resultset('Master')->create({ id => 1 });
 
@@ -4,16 +4,14 @@ use Test::More tests => 1;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $form = HTML::FormFu->new;
 
 $form->load_config_file('t/update/basic.yml');
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,14 +4,12 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $config_file = 't/x_roundtrip/checkbox.yml';
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');
 
@@ -4,14 +4,12 @@ use Test::More tests => 3;
 
 use HTML::FormFu;
 use lib 't/lib';
-use DBICTestLib 'new_db';
+use DBICTestLib 'new_schema';
 use MySchema;
 
-new_db();
-
 my $config_file = 't/x_roundtrip/checkbox.yml';
 
-my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+my $schema = new_schema();
 
 my $rs = $schema->resultset('Master');